import { i18n } from 'boot/i18n.js'
import { yesOrNo } from 'src/enum/index.js'
import { directional, directions, rackCategory, rackFixedTypes } from 'src/views/CarrierCore/enum.js'

export const formatColumns = (rowInfo = {}) => {
  const shelfType = (rowInfo.shelfType || '').toUpperCase()
  return [{
    label: `${i18n.t('CarrierCore.RackType')}`, field: 'shelfTypeName',
    format: (_, row) => `${row.shelfTypeNo}_${row.shelfTypeName}`
  }, {
    label: `${i18n.t('CarrierCore.RackCategory')}`, field: 'shelfType', type: 'select', options: rackCategory.value
  }, {
    label: `${i18n.t('Misc.FixedType')}`, field: 'shelfTypStyle', options: rackFixedTypes.value, useTag: true,
    defaultValue: i18n.t('Misc.NonFixed')
  }, {
    label: `${i18n.t('CarrierCore.MovableRackCompatible')}`, field: 'isBlindLift', options: yesOrNo.value, useTag: true,
    display: rowInfo.shelfTypStyle === '1'
  }, {
    label: `${i18n.t('CarrierCore.RackParams')}`, field: 'rackParam', minWidth: 100, hide: true, search: false,
    format: (_, row) => {
      if (row.isFixed === '1') return `${row.shelfLength || 0}x${row.shelfWidth || 0}mm`
      return `${row.shelfLength || 0}x${row.shelfWidth || 0}mm ${row.shelfWeight || 0}kg`
    }
  }, {
    label: `${i18n.t('Misc.LegSize')}`, field: 'LegSize', display: ['NORMAL', 'DRAG'].includes(shelfType),
    format: (_, row) => `${row.shelfLegLength || 0}x${row.shelfLegWidth || 0}x${row.shelfLegHeight || 0}mm`
  }, {
    label: `${i18n.t('Misc.InnerDiameter')}`, field: 'InnerDiameter', display: ['NORMAL', 'DRAG'].includes(shelfType),
    format: (_, row) => `${row.shelfInnerX || 0}x${row.shelfInnerY || 0}mm`
  }, {
    label: `${i18n.t('Misc.IsBlindLift')}`, field: 'isBlindLift', options: yesOrNo.value, useTag: true
  }, {
    label: `${i18n.t('Misc.ESDChainBafflePosition')}`, field: 'chainBaffleBearing', options: directional.value,
    display: ['NORMAL', 'DRAG'].includes(shelfType)
  }, {
    label: `${i18n.t('Misc.ESDChainSize')}`, field: 'chainSize', unit: 'mm',
    display: ['NORMAL', 'DRAG'].includes(shelfType) && rowInfo.chainBaffleBearing !== '-1'
  }, {
    label: `${i18n.t('Misc.BeamDirection')}`, field: 'beamDirection', options: directional.value,
    display: ['NORMAL', 'DRAG'].includes(shelfType)
  }, {
    label: `${i18n.t('Misc.BeamHeight')}`, field: 'barHeight',
    display: ['NORMAL', 'DRAG'].includes(shelfType) && rowInfo.beamDirection !== '-1'
  }, {
    label: `${i18n.t('CarrierCore.RackLevels')}`, field: 'shelfLayerNumber'
  }, {
    label: `${i18n.t('Misc.PickDirection')}`, field: 'shelfDirection', options: directions.value, multiple: true
  }].filter(el => el.display !== false)
}